﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Text;

using DataTestFramework.EntityFramework4;
using DataTestFramework.Infrastructure;
using DataTestFramework.NHibernate;


namespace DataTestFramework
{
    class Program
    {
        private static readonly Stopwatch Watch = new Stopwatch();
        static void Main()
        {
            DataInitializer.Initialize();
            bool exit = false;
            while (true)
            {
                try
                {
                    Console.WriteLine("\n请输入命令——帮助：h，退出程序：0，功能命令：1 - n");
                    string input = Console.ReadLine();
                    if (input == null)
                    {
                        continue;
                    }
                    switch (input.ToLower())
                    {
                        case "h":
                            HelpInfo();
                            break;
                        case "0":
                            exit = true;
                            break;
                        case "1":
                            Method01();
                            break;
                        case "2":
                            Method02();
                            break;
                        case "3":
                            Method03();
                            break;
                        case "4":
                            Method04();
                            break;
                        case "5":
                            Method05();
                            break;
                        case "6":
                            Method06();
                            break;
                        case "7":
                            Method07();
                            break;
                        case "8":
                            Method08();
                            break;
                        case "9":
                            Method09();
                            break;
                        case "10":
                            Method10();
                            break;
                        case "11":
                            Method11();
                            break;
                        case "12":
                            Method12();
                            break;
                        case "13":
                            Method13();
                            break;
                        case "14":
                            Method14();
                            break;
                    }
                    if (exit)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    while (e.InnerException != null)
                    {
                        Console.WriteLine("内部异常：");
                        Console.WriteLine(e.InnerException.Message);
                        Console.WriteLine(e.InnerException.StackTrace);
                        e = e.InnerException;
                    }
                }
            }
        }

        private static void HelpInfo()
        {
            Console.WriteLine("=============帮-助-信-息============");
            Console.WriteLine("h.帮助信息");
            Console.WriteLine("0.退出程序");
            Console.WriteLine("1.性能测试——EntityFramework");
            Console.WriteLine("2.性能测试——NHibernate");
            Console.WriteLine("=============帮-助-信-息============");
        }

        private static void Method01()
        {
            Console.WriteLine("=============EntityFramework测试开始============");
            EntityFrameworkTester tester = new EntityFrameworkTester();
            tester.Work();
            Console.WriteLine("=============EntityFramework测试结束============");
        }

        private static void Method02()
        {
            Console.WriteLine("=============NHibernate测试开始============");
            NHibernateTester tester = new NHibernateTester();
            tester.Work();
            Console.WriteLine("=============NHibernate测试结束============");
        }

        private static void Method03()
        {
        }

        private static void Method04()
        {
            throw new NotImplementedException();
        }

        private static void Method05()
        {
            throw new NotImplementedException();
        }

        private static void Method06()
        {
            throw new NotImplementedException();
        }

        private static void Method07()
        {
            throw new NotImplementedException();
        }

        private static void Method08()
        {
            throw new NotImplementedException();
        }

        private static void Method09()
        {
            throw new NotImplementedException();
        }

        private static void Method10()
        {
            throw new NotImplementedException();
        }

        private static void Method11()
        {
            throw new NotImplementedException();
        }

        private static void Method12()
        {
            throw new NotImplementedException();
        }

        private static void Method13()
        {
            throw new NotImplementedException();
        }

        private static void Method14()
        {
            throw new NotImplementedException();
        }

    }
}
